package com.zephyr.vchcenter.bpm.action;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.context.ApplicationContext;

import com.hiaward.bpm.action.TaskAction;
import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.ServiceException;
import com.hiaward.framework.taskmanage.service.Service;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.bpm.util.RandomUtil;
import com.zephyr.vchcenter.dao.IBaseDao;
import com.zephyr.vchcenter.helper.SpringHelper;

public class RefuseAction extends TaskAction {
	private final Logger log=Logger.getLogger(RefuseAction.class);
	@Override
	public void perform(ServiceContext arg0) throws ServiceException,
			ParameterException {
		log.debug("���进入RefuseAction===========================");
		
		//���ݲ���
		String vchsid=(String)arg0.getInputParameterValue("vchsid");
		log.debug("------>");
		String accno=(String)arg0.getInputParameterValue("accno");
        String amount=(String)arg0.getInputParameterValue("amount");
        String vchno=(String)arg0.getInputParameterValue("vchno");
        String brbank=(String)arg0.getInputParameterValue("brbank");
        String vsbank=(String)arg0.getInputParameterValue("vsbank");
        
        String vchtype=(String)arg0.getInputParameterValue("vchtype");
        String vchdate=(String)arg0.getInputParameterValue("vchdate");
        String vchpwd=(String)arg0.getInputParameterValue("vchpwd");
        String rtreason=(String)arg0.getInputParameterValue("rtreason");
	    log.debug("accno: " + accno + "vchno: " + vchno);
		//ȡ������id
		//Long processInstanceId=arg0.getToken().getProcessInstance().getId();
		
		IBaseDao dao=(IBaseDao)SpringHelper.getBean("baseDao");
        Voucher voucher=(Voucher)dao.findById("Voucher", vchsid);
		voucher.setAccno(accno);
		voucher.setVchno(vchno);
		voucher.setVchdate(vchdate);
		voucher.setVchtype(vchtype);
		voucher.setVchpwd(vchpwd);
        voucher.setAmount(amount);
        voucher.setRtreason(rtreason);
        voucher.setBrbank(brbank);
        voucher.setVsbank(vsbank);
        voucher.setTallytype("4");
        dao.saveOrUpdate(voucher);
	    /*ApplicationContext applicationContext=randomUtil.getApplicationContext();
	    Service baseService=(Service)applicationContext.getBean("daoService");
	    baseService.saveObject(voucher);*/
	    
	    //����ҳ�����
		
	    log.debug("���离开RefuseAction===================");
	}
	
	@Override
	public void serviceExceptionHandle(ServiceContext arg0,
			ServiceException arg1) {
	

	}

}
